﻿<?php
require_once './lib.php';
header("Content-type:text/html;charset=utf-8");
$mysql = new DBAccess();
/**
 * @param $table 需要更新的表
 * @param $qishu 期数
 */
function upDataInTable($table, $qishu)
{
    $mysql = new DBAccess();
    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu";
    $mysql->query($sql);

    //将广东快乐十分结果表状态修改为正常
    $sql = "update $table set state='1' WHERE state='0' AND qishu=$qishu";
    $mysql->query($sql);
}

//将数据表查询的最新一期期号放入数组
$arr = array();

//重庆时时彩最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5 from lottery_result_cq WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['CQ'] = $result;

//北京PK拾最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5,ball_6,ball_7,ball_8,ball_9,ball_10 from lottery_result_bjpk WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['BJPK'] = $result;

//排列3最新期号
$sql = "select qishu,ball_1,ball_2,ball_3 from lottery_result_p3 WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['P3'] = $result;

//福彩3D最新期号
$sql = "select qishu,ball_1,ball_2,ball_3 from lottery_result_d3 WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['D3'] = $result;

//广东11选5最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5 from lottery_result_gd11 WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['GD11'] = $result;

//天津时时彩最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5 from lottery_result_tj WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['TJ'] = $result;

//广西十分彩最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5 from lottery_result_gxsf WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['GXSF'] = $result;

//广东快乐十分最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5,ball_6,ball_7,ball_8 from lottery_result_gdsf WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['GDSF'] = $result;

//天津快乐十分最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5,ball_6,ball_7,ball_8 from lottery_result_tjsf WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['TJSF'] = $result;

//上海时时乐（修改江苏快3）
$sql = "select qishu,ball_1,ball_2,ball_3 from lottery_result_t3 WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['T3'] = $result;

//北京快乐8最新期号
$sql = "select qishu,ball_1,ball_2,ball_3,ball_4,ball_5,ball_6,ball_7,ball_8,ball_9,ball_10,ball_11,ball_12,ball_13,ball_14,ball_15,ball_16,ball_17,ball_18,ball_19,ball_20 from lottery_result_bjkn WHERE state = 0 ORDER by id DESC  limit 1";
$result = $mysql->getRow($sql);
$arr['BJKN'] = $result;


//定义相关数组
$dx = array('大', '小');
$ds = array('单', '双');
$lh = array('龙', '虎', '和');
$wdx = array('尾大', '尾小');
$hds = array('合数单', '合数双');
$fw = array('东', '南', '西', '北');
$zfb = array('中', '发', '白');
$num = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21');

//存在重庆时时彩最新一期未结算
if (!empty($arr['CQ'])) {
    //对开奖结果进行换算规则
    $niuniu = b5_niuniu($arr['CQ']['ball_1'], $arr['CQ']['ball_2'], $arr['CQ']['ball_3'], $arr['CQ']['ball_4'], $arr['CQ']['ball_5']);
    $qishu_cq = $arr['CQ']['qishu'];
    //$hm存放球号
    $hm[] = $arr['CQ']['ball_1'];//第一个球
    $hm[] = $arr['CQ']['ball_2'];//第二个球
    $hm[] = $arr['CQ']['ball_3'];//第三个球
    $hm[] = $arr['CQ']['ball_4'];//第四个球
    $hm[] = $arr['CQ']['ball_5'];//第五个球
    //$hms存放规则
    $hms['zhs'][] = Ssc_Auto($hm, 1);//算总和
    $hms['zh'][] = Ssc_Auto($hm, 2);//算总和大小
    $hms['zh'][] = Ssc_Auto($hm, 3);//算总和单双
    $hms['zh'][] = Ssc_Auto($hm, 4);//算龙虎和
    $hms['three'][] = Ssc_Auto($hm, 5);//算前三
    $hms['three'][] = Ssc_Auto($hm, 6);//算中三
    $hms['three'][] = Ssc_Auto($hm, 7);//算后三
    $hms['niuniu'][] = $niuniu;//牛牛
    $hms['niuniu'][] = b5_niuds($niuniu);//牛大
    $hms['niuniu'][] = b5_niudx($niuniu);//牛小

    $sql = "select order_num,order_sub_num,quick_type,number,win,fs,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_cq AND Gtype='CQ') AND status=0";
    $res = $mysql->getRows($sql);

    //定义数组存放订单开奖结果
    $zjresultall = array();

    foreach ($res as $k => $v) {
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm[3]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm[4]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], $hms['zh'])) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "前三") {
            if ($v['number'] == $hms['three'][0]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "中三") {
            if ($v['number'] == $hms['three'][1]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "后三") {
            if ($v['number'] == $hms['three'][2]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "牛牛") {
            if (in_array($v['number'], $hms['niuniu'])) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }

//判断订单存在且不为空，进行退钱操作
    if (isset($zjresultall) && !empty($zjresultall)) {
        //var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {//依次退钱
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = $v['win'];

            //查询用户id
            $sql = "SELECT user_id FROM order_lottery WHERE order_num=$v[order_num]";
            $user_id = $mysql->getValue($sql);

            //查询用户前资产
            $sql = "SELECT money FROM user_list WHERE user_id= $user_id";
            $rsMoney = $mysql->getValue($sql);
            $assets = round($rsMoney, 2);

            //更新用户金额
            $sql_money = "update user_list set money=money+$win WHERE user_id=$user_id";
            $mysql->query($sql_money);

            $balance = $assets + $win;

            //插入金钱记录
            $sql = "INSERT INTO `money_log` (`user_id`,`order_num`,`about`,`update_time`,`type`,`order_value`,`assets`,`balance`)
                VALUES ('$user_id','$v[order_sub_num]','重庆时时彩',now(),'$v[type]','$win','$assets','$balance');";
            $mysql->query($sql) or die ("插入金钱记录失败!!!");
        }
    }

   // upDataInTable('lottery_result_cq',$qishu_cq);
//将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_cq";
    $mysql->query($sql);

//将时时彩结果表状态修改为正常
    $sql = "update lottery_result_cq set state='1' WHERE state='0' AND qishu=$qishu_cq";
    $mysql->query($sql);

}
//存在北京PK拾最新一期未结算
if (!empty($arr['BJPK'])) {
    $qishu_bjpk = $arr['BJPK']['qishu'];
    $hm1[] = $arr['BJPK']['ball_1'];
    $hm1[] = $arr['BJPK']['ball_2'];
    $hm1[] = $arr['BJPK']['ball_3'];
    $hm1[] = $arr['BJPK']['ball_4'];
    $hm1[] = $arr['BJPK']['ball_5'];
    $hm1[] = $arr['BJPK']['ball_6'];
    $hm1[] = $arr['BJPK']['ball_7'];
    $hm1[] = $arr['BJPK']['ball_8'];
    $hm1[] = $arr['BJPK']['ball_9'];
    $hm1[] = $arr['BJPK']['ball_10'];
    $hms1[] = Pk10_Auto_quick($hm1, 1);
    $hms1[] = Pk10_Auto_quick($hm1, 2);
    $hms1[] = Pk10_Auto_quick($hm1, 3);
    $hms1[] = Pk10_Auto_quick($hm1, 4);
    $hms1[] = Pk10_Auto_quick($hm1, 5);
    $hms1[] = Pk10_Auto_quick($hm1, 6);
    $hms1[] = Pk10_Auto_quick($hm1, 7);
    $hms1[] = Pk10_Auto_quick($hm1, 8);

    $sql = "select order_num,order_sub_num,quick_type,number,win,fs,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_bjpk AND Gtype='BJPK') AND status=0";
    $res1 = $mysql->getRows($sql);

    //定义数组存放订单开奖结果
    $zjresultall = array();

    foreach ($res1 as $k => $v) {
        if ($v['quick_type'] == "冠亚军和") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hms1[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == $hms1[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == $hms1[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "冠军") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm1[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $lh)) {
                if ($v['number'] == $hms1[3]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "亚军") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm1[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $lh)) {
                if ($v['number'] == $hms1[4]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三名") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm1[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $lh)) {
                if ($v['number'] == $hms1[5]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四名") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm1[3]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $lh)) {
                if ($v['number'] == $hms1[6]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五名") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm1[4]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $lh)) {
                if ($v['number'] == $hms1[7]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第六名") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm1[5]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第七名") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm1[6]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第八名") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm1[7]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第九名") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm1[8]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[8])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[8])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第十名") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm1[9]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Pk10_Auto($hm1, 9, $hm1[9])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Pk10_Auto($hm1, 10, $hm1[9])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }

    }

    //判断订单存在且不为空，进行退钱操作
    if (isset($zjresultall) && !empty($zjresultall)) {
        //var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {//依次退钱
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = $v['win'];

            //查询用户id
            $sql = "SELECT user_id FROM order_lottery WHERE order_num=$v[order_num]";
            $user_id = $mysql->getValue($sql);

            //查询用户前资产
            $sql = "SELECT money FROM user_list WHERE user_id= $user_id";
            $rsMoney = $mysql->getValue($sql);
            $assets = round($rsMoney, 2);

            //更新用户金额
            $sql_money = "update user_list set money=money+$win WHERE user_id=$user_id";
            $mysql->query($sql_money);

            $balance = $assets + $win;

            //插入金钱记录
            $sql = "INSERT INTO `money_log` (`user_id`,`order_num`,`about`,`update_time`,`type`,`order_value`,`assets`,`balance`)
                VALUES ('$user_id','$v[order_sub_num]','北京PK拾',now(),'$v[type]','$win','$assets','$balance');";
            $mysql->query($sql) or die ("插入金钱记录失败!!!");
        }
    }

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_bjpk";
    $mysql->query($sql);

    //将北京PK结果表状态修改为正常
    $sql = "update lottery_result_bjpk set state='1' WHERE state='0' AND qishu=$qishu_bjpk";
    $mysql->query($sql);

}
//存在排列3最新一期未结算
if (!empty($arr['P3'])) {
    $qishu_p3 = substr($arr['P3']['qishu'],2);//取数据时截取
    $hm2[] = $arr['P3']['ball_1'];
    $hm2[] = $arr['P3']['ball_2'];
    $hm2[] = $arr['P3']['ball_3'];
    $hms2[] = f3D_Auto($hm2, 1);
    $hms2[] = f3D_Auto($hm2, 2);
    $hms2[] = f3D_Auto($hm2, 3);
    $hms2[] = f3D_Auto($hm2, 4);
    $hms2[] = f3D_Auto($hm2, 5);
    $hms2[] = f3D_Auto($hm2, 6);
    $sql = "select order_num,order_sub_num,quick_type,fs,number,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_p3 AND Gtype='P3') AND status=0";
    $res2 = $mysql->getRows($sql);

    //定义数组存放订单开奖结果
    $zjresultall = array();

    foreach ($res2 as $k => $v) {
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm2[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm2[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm2[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm2[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm2[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm2[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm2[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm2[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm2[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], array($hms2[1], $hms2[2], $hms2[3]))) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "三连") {
            if ($v['number'] == $hms2['4']) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "跨度") {
            if ($v['number'] == $hms2['5']) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }

    //判断订单存在且不为空，进行退钱操作
    if (isset($zjresultall) && !empty($zjresultall)) {
        //var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {//依次退钱
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = $v['win'];

            //查询用户id
            $sql = "SELECT user_id FROM order_lottery WHERE order_num=$v[order_num]";
            $user_id = $mysql->getValue($sql);

            //查询用户前资产
            $sql = "SELECT money FROM user_list WHERE user_id= $user_id";
            $rsMoney = $mysql->getValue($sql);
            $assets = round($rsMoney, 2);

            //更新用户金额
            $sql_money = "update user_list set money=money+$win WHERE user_id=$user_id";
            $mysql->query($sql_money);

            $balance = $assets + $win;

            //插入金钱记录
            $sql = "INSERT INTO `money_log` (`user_id`,`order_num`,`about`,`update_time`,`type`,`order_value`,`assets`,`balance`)
                VALUES ('$user_id','$v[order_sub_num]','排列3',now(),'$v[type]','$win','$assets','$balance');";
            $mysql->query($sql) or die ("插入金钱记录失败!!!");
        }
    }

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_p3";
    $mysql->query($sql);

    //将排列3结果表状态修改为正常
    $sql = "update lottery_result_p3 set state='1' WHERE state='0' AND qishu=$qishu_p3";
    $mysql->query($sql);
}
//存在福彩3D最新一期未结算
if (!empty($arr['D3'])) {
    $qishu_d3 = $arr['D3']['qishu'];
    $hm3[] = $arr['D3']['ball_1'];
    $hm3[] = $arr['D3']['ball_2'];
    $hm3[] = $arr['D3']['ball_3'];
    $hms3[] = f3D_Auto($hm3, 1);
    $hms3[] = f3D_Auto($hm3, 2);
    $hms3[] = f3D_Auto($hm3, 3);
    $hms3[] = f3D_Auto($hm3, 4);
    $hms3[] = f3D_Auto($hm3, 5);
    $hms3[] = f3D_Auto($hm3, 6);

    $sql = "select order_num,order_sub_num,quick_type,number,fs,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_d3 AND Gtype='D3') AND status=0";
    $res3 = $mysql->getRows($sql);

    //定义数组存放订单开奖结果
    $zjresultall = array();

    foreach ($res3 as $k => $v) {
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm3[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm3[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm3[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm3[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm3[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm3[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm3[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm3[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm3[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], array($hms3[1], $hms3[2], $hms3[3]))) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "三连") {
            if ($v['number'] == $hms3['4']) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "跨度") {
            if ($v['number'] == $hms3['5']) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }

    //判断订单存在且不为空，进行退钱操作
    if (isset($zjresultall) && !empty($zjresultall)) {
        //var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {//依次退钱
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = $v['win'];

            //查询用户id
            $sql = "SELECT user_id FROM order_lottery WHERE order_num=$v[order_num]";
            $user_id = $mysql->getValue($sql);

            //查询用户前资产
            $sql = "SELECT money FROM user_list WHERE user_id= $user_id";
            $rsMoney = $mysql->getValue($sql);
            $assets = round($rsMoney, 2);

            //更新用户金额
            $sql_money = "update user_list set money=money+$win WHERE user_id=$user_id";
            $mysql->query($sql_money);

            $balance = $assets + $win;

            //插入金钱记录
            $sql = "INSERT INTO `money_log` (`user_id`,`order_num`,`about`,`update_time`,`type`,`order_value`,`assets`,`balance`)
                VALUES ('$user_id','$v[order_sub_num]','福彩3D',now(),'$v[type]','$win','$assets','$balance');";
            $mysql->query($sql) or die ("插入金钱记录失败!!!");
        }
    }

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_d3";
    $mysql->query($sql);

    //将福彩3D结果表状态修改为正常
    $sql = "update lottery_result_d3 set state='1' WHERE state='0' AND qishu=$qishu_d3";
    $mysql->query($sql);


}
//存在广东11选5最新一期未结算
if (!empty($arr['GD11'])) {
    $qishu_gd11 = $arr['GD11']['qishu'];
    $hm4[] = $arr['GD11']['ball_1'];
    $hm4[] = $arr['GD11']['ball_2'];
    $hm4[] = $arr['GD11']['ball_3'];
    $hm4[] = $arr['GD11']['ball_4'];
    $hm4[] = $arr['GD11']['ball_5'];
    $hms4[] = gd11x5_Auto($hm4, 1);
    $hms4[] = gd11x5_Auto($hm4, 2);
    $hms4[] = gd11x5_Auto($hm4, 3);
    $hms4[] = gd11x5_Auto($hm4, 4);
    $hms4[] = gd11x5_Auto($hm4, 5);
    $hms4[] = gd11x5_Auto($hm4, 6);
    $hms4[] = gd11x5_Auto($hm4, 7);

    $sql = "select order_num,order_sub_num,quick_type,number,bet_money,win,status,is_win,fs from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_gd11 AND Gtype='GD11') AND status=0";
    $res4 = $mysql->getRows($sql);

    //定义数组存放订单开奖结果
    $zjresultall = array();

    foreach ($res4 as $k => $v) {
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm4[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == gd11x5_Dx($hm4[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == gd11x5_Ds($hm4[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm4[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == gd11x5_Dx($hm4[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == gd11x5_Ds($hm4[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm4[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == gd11x5_Dx($hm4[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == gd11x5_Ds($hm4[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm4[3]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == gd11x5_Dx($hm4[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == gd11x5_Ds($hm4[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm4[4]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == gd11x5_Dx($hm4[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == gd11x5_Ds($hm4[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], array('总和大', '总和小'))) {
                if ($hms4[0] == 30) {//和为30，平局
                    $array = array("win" => $v['bet_money'], "is_win" => 2, "type" => "彩票自动结算-彩票平局", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    if ($v['number'] == $hms4[1]) {
                        $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                        array_push($zjresultall, $array);
                    } else {
                        $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                        array_push($zjresultall, $array);
                    }
                }
            }
            if (in_array($v['number'], array('总和单', '总和双'))) {
                if ($v['number'] == $hms4[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $lh)) {
                if ($v['number'] == $hms4[3]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "前三") {
            if ($v['number'] == $hms4[4]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "中三") {
            if ($v['number'] == $hms4[5]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "后三") {
            if ($v['number'] == $hms4[6]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }

    //判断订单存在且不为空，进行退钱操作
    if (isset($zjresultall) && !empty($zjresultall)) {
        //var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {//依次退钱
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = $v['win'];

            //查询用户id
            $sql = "SELECT user_id FROM order_lottery WHERE order_num=$v[order_num]";
            $user_id = $mysql->getValue($sql);

            //查询用户前资产
            $sql = "SELECT money FROM user_list WHERE user_id= $user_id";
            $rsMoney = $mysql->getValue($sql);
            $assets = round($rsMoney, 2);

            //更新用户金额
            $sql_money = "update user_list set money=money+$win WHERE user_id=$user_id";
            $mysql->query($sql_money);

            $balance = $assets + $win;

            //插入金钱记录
            $sql = "INSERT INTO `money_log` (`user_id`,`order_num`,`about`,`update_time`,`type`,`order_value`,`assets`,`balance`)
                VALUES ('$user_id','$v[order_sub_num]','广东11选5',now(),'$v[type]','$win','$assets','$balance');";
            $mysql->query($sql) or die ("插入金钱记录失败!!!");
        }
    }

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_gd11";
    $mysql->query($sql);

    //将广东11选5结果表状态修改为正常
    $sql = "update lottery_result_gd11 set state='1' WHERE state='0' AND qishu=$qishu_gd11";
    $mysql->query($sql);
}
//存在天津时时彩最新一期未结算
if (!empty($arr['TJ'])) {
    //对开奖结果进行换算规则
    $niuniu1 = b5_niuniu($arr['TJ']['ball_1'], $arr['TJ']['ball_2'], $arr['TJ']['ball_3'], $arr['TJ']['ball_4'], $arr['TJ']['ball_5']);
    $qishu_tj = $arr['TJ']['qishu'];
    //$hm存放球号
    $hm5[] = $arr['TJ']['ball_1'];//第一个球
    $hm5[] = $arr['TJ']['ball_2'];//第二个球
    $hm5[] = $arr['TJ']['ball_3'];//第三个球
    $hm5[] = $arr['TJ']['ball_4'];//第四个球
    $hm5[] = $arr['TJ']['ball_5'];//第五个球
    //$hms存放规则
    $hms5['zhs'][] = Ssc_Auto($hm5, 1);//算总和
    $hms5['zh'][] = Ssc_Auto($hm5, 2);//算总和大小
    $hms5['zh'][] = Ssc_Auto($hm5, 3);//算总和单双
    $hms5['zh'][] = Ssc_Auto($hm5, 4);//算龙虎和
    $hms5['three'][] = Ssc_Auto($hm5, 5);//算前三
    $hms5['three'][] = Ssc_Auto($hm5, 6);//算中三
    $hms5['three'][] = Ssc_Auto($hm5, 7);//算后三
    $hms5['niuniu'][] = $niuniu1;//牛牛
    $hms5['niuniu'][] = b5_niuds($niuniu1);//牛大
    $hms5['niuniu'][] = b5_niudx($niuniu1);//牛小

    $sql = "select order_num,order_sub_num,quick_type,number,win,status,is_win,fs from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_tj AND Gtype='TJ') AND status=0";
    $res5 = $mysql->getRows($sql);

    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res5 as $k => $v) {
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm5[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm5[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm5[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm5[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm5[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm5[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm5[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm5[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm5[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm5[3]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm5[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm5[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm5[4]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm5[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm5[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], $hms5['zh'])) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "前三") {
            if ($v['number'] == $hms5['three'][0]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "中三") {
            if ($v['number'] == $hms5['three'][1]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "后三") {
            if ($v['number'] == $hms5['three'][2]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "牛牛") {
            if (in_array($v['number'], $hms5['niuniu'])) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }

    //判断订单存在且不为空，进行退钱操作
    if (isset($zjresultall) && !empty($zjresultall)) {
        //var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {//依次退钱
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = $v['win'];

            //查询用户id
            $sql = "SELECT user_id FROM order_lottery WHERE order_num=$v[order_num]";
            $user_id = $mysql->getValue($sql);

            //查询用户前资产
            $sql = "SELECT money FROM user_list WHERE user_id= $user_id";
            $rsMoney = $mysql->getValue($sql);
            $assets = round($rsMoney, 2);

            //更新用户金额
            $sql_money = "update user_list set money=money+$win WHERE user_id=$user_id";
            $mysql->query($sql_money);

            $balance = $assets + $win;

            //插入金钱记录
            $sql = "INSERT INTO `money_log` (`user_id`,`order_num`,`about`,`update_time`,`type`,`order_value`,`assets`,`balance`)
                VALUES ('$user_id','$v[order_sub_num]','天津时时彩',now(),'$v[type]','$win','$assets','$balance');";
            $mysql->query($sql) or die ("插入金钱记录失败!!!");
        }
    }

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_tj";
    $mysql->query($sql);

    //将天津时时彩结果表状态修改为正常
    $sql = "update lottery_result_tj set state='1' WHERE state='0' AND qishu=$qishu_tj";
    $mysql->query($sql);
}
//存在广西十分彩最新一期未结算
if (!empty($arr['GXSF'])) {
    $qishu_gxsf = $arr['GXSF']['qishu'];
    $hm6[] = $arr['GXSF']['ball_1'];
    $hm6[] = $arr['GXSF']['ball_2'];
    $hm6[] = $arr['GXSF']['ball_3'];
    $hm6[] = $arr['GXSF']['ball_4'];
    $hm6[] = $arr['GXSF']['ball_5'];
    $hms6[] = gxsf_Auto($hm6, 1);
    $hms6[] = gxsf_Auto($hm6, 2);
    $hms6[] = gxsf_Auto($hm6, 3);
    $hms6[] = gxsf_Auto($hm6, 4);
    $hms6[] = gxsf_Auto($hm6, 5);
    $hms6[] = gxsf_Auto($hm6, 6);
    $hms6[] = gxsf_Auto($hm6, 7);

    $sql = "select order_num,order_sub_num,quick_type,number,bet_money,win,fs,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_gxsf AND Gtype='GXSF') AND status=0";
    $res6 = $mysql->getRows($sql);

    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res6 as $k => $v) {
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx) || in_array($v['number'], $ds)) {
                if ($hm6[0] == 21) {//如果为21为平局，退回下注金额
                    $array = array("win" => $v['bet_money'], "is_win" => 2, "type" => "彩票自动结算-彩票平局", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } elseif (in_array($v['number'], $dx) && $v['number'] == gxsf_Dx($hm6[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } elseif (in_array($v['number'], $ds) && $v['number'] == gxsf_Ds($hm6[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }

        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx) || in_array($v['number'], $ds)) {
                if ($hm6[1] == 21) {//如果为21为平局，退回下注金额
                    $array = array("win" => $v['bet_money'], "is_win" => 2, "type" => "彩票自动结算-彩票平局", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } elseif (in_array($v['number'], $dx) && $v['number'] == gxsf_Dx($hm6[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } elseif (in_array($v['number'], $ds) && $v['number'] == gxsf_Ds($hm6[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }

        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx) || in_array($v['number'], $ds)) {
                if ($hm6[2] == 21) {//如果为21为平局，退回下注金额
                    $array = array("win" => $v['bet_money'], "is_win" => 2, "type" => "彩票自动结算-彩票平局", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } elseif (in_array($v['number'], $dx) && $v['number'] == gxsf_Dx($hm6[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } elseif (in_array($v['number'], $ds) && $v['number'] == gxsf_Ds($hm6[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[3]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx) || in_array($v['number'], $ds)) {
                if ($hm6[3] == 21) {//如果为21为平局，退回下注金额
                    $array = array("win" => $v['bet_money'], "is_win" => 2, "type" => "彩票自动结算-彩票平局", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } elseif (in_array($v['number'], $dx) && $v['number'] == gxsf_Dx($hm6[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } elseif (in_array($v['number'], $ds) && $v['number'] == gxsf_Ds($hm6[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm6[4]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx) || in_array($v['number'], $ds)) {
                if ($hm6[4] == 21) {//如果为21为平局，退回下注金额
                    $array = array("win" => $v['bet_money'], "is_win" => 2, "type" => "彩票自动结算-彩票平局", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } elseif (in_array($v['number'], $dx) && $v['number'] == gxsf_Dx($hm6[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } elseif (in_array($v['number'], $ds) && $v['number'] == gxsf_Ds($hm6[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], array($hms6[1], $hms6[2], $hms6[3]))) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "前三") {
            if ($v['number'] == $hms6[4]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "中三") {
            if ($v['number'] == $hms6[5]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "后三") {
            if ($v['number'] == $hms6[6]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }

    //判断订单存在且不为空，进行退钱操作
    if (isset($zjresultall) && !empty($zjresultall)) {
        //var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {//依次退钱
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = $v['win'];

            //查询用户id
            $sql = "SELECT user_id FROM order_lottery WHERE order_num=$v[order_num]";
            $user_id = $mysql->getValue($sql);

            //查询用户前资产
            $sql = "SELECT money FROM user_list WHERE user_id= $user_id";
            $rsMoney = $mysql->getValue($sql);
            $assets = round($rsMoney, 2);

            //更新用户金额
            $sql_money = "update user_list set money=money+$win WHERE user_id=$user_id";
            $mysql->query($sql_money);

            $balance = $assets + $win;

            //插入金钱记录
            $sql = "INSERT INTO `money_log` (`user_id`,`order_num`,`about`,`update_time`,`type`,`order_value`,`assets`,`balance`)
                VALUES ('$user_id','$v[order_sub_num]','广西十分彩',now(),'$v[type]','$win','$assets','$balance');";
            $mysql->query($sql) or die ("插入金钱记录失败!!!");
        }
    }

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_gxsf";
    $mysql->query($sql);

    //将广西十分彩结果表状态修改为正常
    $sql = "update lottery_result_gxsf set state='1' WHERE state='0' AND qishu=$qishu_gxsf";
    $mysql->query($sql);

}
//存在广东快乐十分最新一期未结算
if (!empty($arr['GDSF'])) {
    $qishu_gdsf = $arr['GDSF']['qishu'];
    $hm7[] = BuLing($arr['GDSF']['ball_1']);
    $hm7[] = BuLing($arr['GDSF']['ball_2']);
    $hm7[] = BuLing($arr['GDSF']['ball_3']);
    $hm7[] = BuLing($arr['GDSF']['ball_4']);
    $hm7[] = BuLing($arr['GDSF']['ball_5']);
    $hm7[] = BuLing($arr['GDSF']['ball_6']);
    $hm7[] = BuLing($arr['GDSF']['ball_7']);
    $hm7[] = BuLing($arr['GDSF']['ball_8']);
    $hms7[] = G10_Auto($hm7, 1);
    $hms7[] = G10_Auto($hm7, 2);
    $hms7[] = G10_Auto($hm7, 3);
    $hms7[] = G10_Auto($hm7, 4);
    $hms7[] = G10_Auto($hm7, 5);

    $sql = "select order_num,order_sub_num,quick_type,number,bet_money,fs,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_gdsf AND Gtype='GDSF') AND status=0";
    $res7 = $mysql->getRows($sql);

    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res7 as $k => $v) {
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm7[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm7[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm7[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm7[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm7[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm7[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm7[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm7[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm7[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[3]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm7[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm7[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm7[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[4]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm7[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm7[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm7[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第六球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[5]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm7[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm7[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm7[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第七球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[6]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm7[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm7[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm7[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第八球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm7[7]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm7[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm7[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm7[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm7[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm7[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm7[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎") {
            if ($hms7[0] == 84 && in_array($v['number'], array('总和大', '总和小'))) {
                $array = array("win" => $v['bet_money'], 'is_win' => 2, "type" => "彩票自动结算-彩票平局", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else if (in_array($v['number'], array($hms7[1], $hms7[2], $hms7[3], $hms7[4]))) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }

    //判断订单存在且不为空，进行退钱操作
    if (isset($zjresultall) && !empty($zjresultall)) {
        //var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {//依次退钱
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = $v['win'];

            //查询用户id
            $sql = "SELECT user_id FROM order_lottery WHERE order_num=$v[order_num]";
            $user_id = $mysql->getValue($sql);

            //查询用户前资产
            $sql = "SELECT money FROM user_list WHERE user_id= $user_id";
            $rsMoney = $mysql->getValue($sql);
            $assets = round($rsMoney, 2);

            //更新用户金额
            $sql_money = "update user_list set money=money+$win WHERE user_id=$user_id";
            $mysql->query($sql_money);

            $balance = $assets + $win;

            //插入金钱记录
            $sql = "INSERT INTO `money_log` (`user_id`,`order_num`,`about`,`update_time`,`type`,`order_value`,`assets`,`balance`)
                VALUES ('$user_id','$v[order_sub_num]','广东快乐十分',now(),'$v[type]','$win','$assets','$balance');";
            $mysql->query($sql) or die ("插入金钱记录失败!!!");
        }
    }
//将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_gdsf";
    $mysql->query($sql);

//将广东快乐十分结果表状态修改为正常
    $sql = "update lottery_result_gdsf set state='1' WHERE state='0' AND qishu=$qishu_gdsf";
    $mysql->query($sql);
}
//存在天津快乐十分最新一期未结算
if (!empty($arr['TJSF'])) {//天津快乐十分
    $qishu_tjsf = $arr['TJSF']['qishu'];
    $hm8[] = BuLing($arr['TJSF']['ball_1']);
    $hm8[] = BuLing($arr['TJSF']['ball_2']);
    $hm8[] = BuLing($arr['TJSF']['ball_3']);
    $hm8[] = BuLing($arr['TJSF']['ball_4']);
    $hm8[] = BuLing($arr['TJSF']['ball_5']);
    $hm8[] = BuLing($arr['TJSF']['ball_6']);
    $hm8[] = BuLing($arr['TJSF']['ball_7']);
    $hm8[] = BuLing($arr['TJSF']['ball_8']);
    $hms8[] = G10_Auto($hm8, 1);
    $hms8[] = G10_Auto($hm8, 2);
    $hms8[] = G10_Auto($hm8, 3);
    $hms8[] = G10_Auto($hm8, 4);
    $hms8[] = G10_Auto($hm8, 5);

    $sql = "select order_num,order_sub_num,quick_type,number,bet_money,win,fs,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_tjsf AND Gtype='TJSF') AND status=0";
    $res8 = $mysql->getRows($sql);

    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res8 as $k => $v) {
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm8[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm8[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm8[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm8[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm8[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm8[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm8[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm8[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm8[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm8[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm8[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm8[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm8[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm8[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm8[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm8[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm8[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm8[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm8[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm8[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm8[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第四球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm8[3]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm8[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm8[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm8[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm8[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm8[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm8[3])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第五球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm8[4]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm8[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm8[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm8[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm8[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm8[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm8[4])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第六球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm8[5]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm8[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm8[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm8[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm8[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm8[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm8[5])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第七球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm8[6]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm8[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm8[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm8[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm8[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm8[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm8[6])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第八球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm8[7]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == G10_Dx($hm8[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == G10_Ds($hm8[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $wdx)) {
                if ($v['number'] == G10_WsDx($hm8[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $hds)) {
                if ($v['number'] == G10_HsDs($hm8[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $fw)) {
                if ($v['number'] == G10_Fw($hm8[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $zfb)) {
                if ($v['number'] == G10_Zfb($hm8[7])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎") {
            if ($hms8[0] == 84 && in_array($v['number'], array('总和大', '总和小'))) {
                $array = array("win" => $v['bet_money'], 'is_win' => 2, "type" => "彩票自动结算-彩票平局", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else if (in_array($v['number'], array($hms8[1], $hms8[2], $hms8[3], $hms8[4]))) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }

    //判断订单存在且不为空，进行退钱操作
    if (isset($zjresultall) && !empty($zjresultall)) {
        //var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {//依次退钱
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = $v['win'];

            //查询用户id
            $sql = "SELECT user_id FROM order_lottery WHERE order_num=$v[order_num]";
            $user_id = $mysql->getValue($sql);

            //查询用户前资产
            $sql = "SELECT money FROM user_list WHERE user_id= $user_id";
            $rsMoney = $mysql->getValue($sql);
            $assets = round($rsMoney, 2);

            //更新用户金额
            $sql_money = "update user_list set money=money+$win WHERE user_id=$user_id";
            $mysql->query($sql_money);

            $balance = $assets + $win;

            //插入金钱记录
            $sql = "INSERT INTO `money_log` (`user_id`,`order_num`,`about`,`update_time`,`type`,`order_value`,`assets`,`balance`)
                VALUES ('$user_id','$v[order_sub_num]','天津快乐十分',now(),'$v[type]','$win','$assets','$balance');";
            $mysql->query($sql) or die ("插入金钱记录失败!!!");
        }
    }

//将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_tjsf";
    $mysql->query($sql);

//将天津快乐十分结果表状态修改为正常
    $sql = "update lottery_result_tjsf set state='1' WHERE state='0' AND qishu=$qishu_tjsf";
    $mysql->query($sql);
}
//存在北京快乐8最新一期未结算
if (!empty($arr['BJKN'])) {
    $qishu_bjkn = $arr['BJKN']['qishu'];
    $hm9[] = $arr['BJKN']['ball_1'];
    $hm9[] = $arr['BJKN']['ball_2'];
    $hm9[] = $arr['BJKN']['ball_3'];
    $hm9[] = $arr['BJKN']['ball_4'];
    $hm9[] = $arr['BJKN']['ball_5'];
    $hm9[] = $arr['BJKN']['ball_6'];
    $hm9[] = $arr['BJKN']['ball_7'];
    $hm9[] = $arr['BJKN']['ball_8'];
    $hm9[] = $arr['BJKN']['ball_9'];
    $hm9[] = $arr['BJKN']['ball_10'];
    $hm9[] = $arr['BJKN']['ball_11'];
    $hm9[] = $arr['BJKN']['ball_12'];
    $hm9[] = $arr['BJKN']['ball_13'];
    $hm9[] = $arr['BJKN']['ball_14'];
    $hm9[] = $arr['BJKN']['ball_15'];
    $hm9[] = $arr['BJKN']['ball_16'];
    $hm9[] = $arr['BJKN']['ball_17'];
    $hm9[] = $arr['BJKN']['ball_18'];
    $hm9[] = $arr['BJKN']['ball_19'];
    $hm9[] = $arr['BJKN']['ball_20'];
    $hms9[] = Kl8_Auto_zh($hm9, 1);
    $hms9[] = Kl8_Auto_zh($hm9, 2);
    $hms9[] = Kl8_Auto_zh($hm9, 3);
    $hms9[] = Kl8_Auto_zh($hm9, 4);
    $hms9[] = Kl8_Auto_zh($hm9, 5);

    $sql = "select order_num,order_sub_num,quick_type,fs,bet_rate,bet_money,number,win,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_bjkn AND Gtype='BJKN') AND status=0";
    $res9 = $mysql->getRows($sql);

    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res9 as $k => $v) {
        if ($v['quick_type'] == "选一") {
            if (in_array($v['number'], $hm9)) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "选二") {
            $num11 = explode(',', $v['number']);
            $y = 0;
            foreach ($num11 as $key => $value) {
                if (in_array($value, $hm9)) {
                    $y++;
                }
            }
            /*for($i=0;$i<2;$i++){
                if (in_array($num11[$i], $hm9)) {
                    $y++;
                }
            }*/
            if ($y == 2) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "选三") {
            $num12 = explode(',', $v['number']);
            $bet_rate2 = explode(',', $v['bet_rate']);
            $y = 0;
            foreach ($num12 as $key => $value) {
                if (in_array($value, $hm9)) {
                    $y++;
                }
            }
            /*for($i=0;$i<3;$i++){
                if (in_array($num12[$i], $hm9)) {
                    $y++;
                }
            }*/
            if ($y == 3) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif ($y == 2) {
                $array = array("win" => $v['bet_money'] * $bet_rate2[1] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "选四") {
            $num13 = explode(',', $v['number']);
            $bet_rate3 = explode(',', $v['bet_rate']);
            $y = 0;
            foreach ($num13 as $key => $value) {
                if (in_array($value, $hm9)) {
                    $y++;
                }
            }
            /*for($i=0;$i<4;$i++){
                if (in_array($num13[$i], $hm9)) {
                    $y++;
                }
            }*/
            if ($y == 4) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif ($y == 3) {
                $array = array("win" => $v['bet_money'] * $bet_rate3[1] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif ($y == 2) {
                $array = array("win" => $v['bet_money'] * $bet_rate3[2] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }

        }
        if ($v['quick_type'] == "选五") {
            $num14 = explode(',', $v['number']);
            $bet_rate4 = explode(',', $v['bet_rate']);
            $y = 0;
            foreach ($num14 as $key => $value) {
                if (in_array($value, $hm9)) {
                    $y++;
                }
            }
            /*for($i=0;$i<5;$i++){
                if (in_array($num14[$i], $hm9)) {
                    $y++;
                }
            }*/
            if ($y == 5) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif ($y == 4) {
                $array = array("win" => $v['bet_money'] * $bet_rate4[1] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } elseif ($y == 3) {
                $array = array("win" => $v['bet_money'] * $bet_rate4[2] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "和值") {
            if ($v['number'] == "总和810") {
                $str_num = str_replace('总和', '', $v['number']);
                if ($str_num == $hms9[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], array('总和大', '总和小'))) {
                if ($v['number'] == $hms9[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], array('总和单', '总和双'))) {
                if ($v['number'] == $hms9[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "上中下") {
            if ($v['number'] == $hms9[3]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "奇和偶") {
            if ($v['number'] == $hms9[4]) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }

    //判断订单存在且不为空，进行退钱操作
    if (isset($zjresultall) && !empty($zjresultall)) {
        //var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {//依次退钱
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = $v['win'];

            //查询用户id
            $sql = "SELECT user_id FROM order_lottery WHERE order_num=$v[order_num]";
            $user_id = $mysql->getValue($sql);

            //查询用户前资产
            $sql = "SELECT money FROM user_list WHERE user_id= $user_id";
            $rsMoney = $mysql->getValue($sql);
            $assets = round($rsMoney, 2);

            //更新用户金额
            $sql_money = "update user_list set money=money+$win WHERE user_id=$user_id";
            $mysql->query($sql_money);

            $balance = $assets + $win;

            //插入金钱记录
            $sql = "INSERT INTO `money_log` (`user_id`,`order_num`,`about`,`update_time`,`type`,`order_value`,`assets`,`balance`)
                VALUES ('$user_id','$v[order_sub_num]','北京快乐十分',now(),'$v[type]','$win','$assets','$balance');";
            $mysql->query($sql) or die ("插入金钱记录失败!!!");
        }
    }

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_bjkn";
    $mysql->query($sql);

    //将北京快乐十分结果表状态修改为正常
    $sql = "update lottery_result_bjkn set state='1' WHERE state='0' AND qishu=$qishu_bjkn";
    $mysql->query($sql);
}
//存在江苏快3最新一期未结算
if (!empty($arr['T3'])) {
    $qishu_t3 = $arr['T3']['qishu'];
    $hm10[] = $arr['T3']['ball_1'];
    $hm10[] = $arr['T3']['ball_2'];
    $hm10[] = $arr['T3']['ball_3'];
    $hms10[] = f3D_Auto($hm10, 1);
    $hms10[] = f3D_Auto($hm10, 2);
    $hms10[] = f3D_Auto($hm10, 3);
    $hms10[] = f3D_Auto($hm10, 4);
    $hms10[] = f3D_Auto($hm10, 5);
    $hms10[] = f3D_Auto($hm10, 6);

    $sql = "select order_num,order_sub_num,quick_type,number,win,fs,status,is_win from order_lottery_sub WHERE order_num=ANY(select order_lottery.order_num from order_lottery WHERE lottery_number=$qishu_t3 AND Gtype='T3') AND status=0";
    $res10 = $mysql->getRows($sql);

    //定义数组存放对应的开奖结果
    $zjresultall = array();

    foreach ($res10 as $k => $v) {
        if ($v['quick_type'] == "第一球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm10[0]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm10[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm10[0])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第二球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm10[1]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm10[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm10[1])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "第三球") {
            if (in_array($v['number'], $num)) {
                if ($v['number'] == $hm10[2]) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $dx)) {
                if ($v['number'] == Ssc_Dx($hm10[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
            if (in_array($v['number'], $ds)) {
                if ($v['number'] == Ssc_Ds($hm10[2])) {
                    $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                } else {
                    $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                    array_push($zjresultall, $array);
                }
            }
        }
        if ($v['quick_type'] == "总和龙虎和") {
            if (in_array($v['number'], array($hms10[1], $hms10[2], $hms10[3]))) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "三连") {
            if ($v['number'] == $hms10['4']) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
        if ($v['quick_type'] == "跨度") {
            if ($v['number'] == $hms10['5']) {
                $array = array("win" => $v['win'] + $v['fs'], "is_win" => 1, "type" => "彩票自动结算-彩票中奖", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            } else {
                $array = array("win" => $v['fs'], "is_win" => 0, "type" => "彩票自动结算-彩票反水", "order_sub_num" => $v['order_sub_num'], "order_num" => $v['order_num']);
                array_push($zjresultall, $array);
            }
        }
    }

    //判断订单存在且不为空，进行退钱操作
    if (isset($zjresultall) && !empty($zjresultall)) {
        //var_dump($zjresultall);
        foreach ($zjresultall as $k => $v) {//依次退钱
            $win = 0.0;
            $set = array('is_win' => $v['is_win'], 'status' => 1);
            $mysql->updateRows_me('order_lottery_sub', $set, "order_num='$v[order_num]' AND order_sub_num='$v[order_sub_num]'");
            $win = $v['win'];

            //查询用户id
            $sql = "SELECT user_id FROM order_lottery WHERE order_num=$v[order_num]";
            $user_id = $mysql->getValue($sql);

            //查询用户前资产
            $sql = "SELECT money FROM user_list WHERE user_id= $user_id";
            $rsMoney = $mysql->getValue($sql);
            $assets = round($rsMoney, 2);

            //更新用户金额
            $sql_money = "update user_list set money=money+$win WHERE user_id=$user_id";
            $mysql->query($sql_money);

            $balance = $assets + $win;

            //插入金钱记录
            $sql = "INSERT INTO `money_log` (`user_id`,`order_num`,`about`,`update_time`,`type`,`order_value`,`assets`,`balance`)
                VALUES ('$user_id','$v[order_sub_num]','江苏快3',now(),'$v[type]','$win','$assets','$balance');";
            $mysql->query($sql) or die ("插入金钱记录失败!!!");
        }
    }

    //将总订单表中状态未结算修改为正常
    $sql = "update order_lottery set status='1' WHERE status='0' AND lottery_number=$qishu_t3";
    $mysql->query($sql);

    //将江苏快3结果表状态修改为正常
    $sql = "update lottery_result_t3 set state='1' WHERE state='0' AND qishu=$qishu_t3";
    $mysql->query($sql);

}
